package com.shuai.dao;

import com.shuai.domain.Student;
import com.shuai.util.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class StudentDao {

    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());

    public Student login(Student loginStudent){

        try {

            //1.定义sql
            String sql = "select * from student1 where username = ? and password =?";
            Student student = template.queryForObject(sql, new BeanPropertyRowMapper<Student>(Student.class), loginStudent.getusername(), loginStudent.getPassword());
            return student;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

}
